/**
 * 
 */
package fhq.hcmute.modernshopping.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import fhq.hcmute.modernshopping.R;

/**
 * @author: Hien Nguyen Le
 * @emai: hien.nguyenle.it@gmail.com
 * 
 */
public class DisplayProductDrawerAdapter extends ArrayAdapter<Drawer> {
	public static final int DRAWER_KEY = 0;
	private Context context;
	private List<Drawer> listDrawers;

	public DisplayProductDrawerAdapter(Context context, List<Drawer> listDrawers) {
		super(context, R.layout.lv_list_item_drawer, listDrawers);
		this.context = context;
		this.listDrawers = listDrawers;
	}

	private static class ViewHolder {
		protected TextView txtDrawerItem;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View rowView = convertView;
		if (rowView == null) {
			LayoutInflater inflater = LayoutInflater.from(context);
			rowView = inflater.inflate(R.layout.lv_list_item_drawer, null);
			ViewHolder viewHolder = new ViewHolder();
			viewHolder.txtDrawerItem = (TextView) rowView
					.findViewById(R.id.txt_drawer_item);
			rowView.setTag(viewHolder);
		}
		ViewHolder holder = (ViewHolder) rowView.getTag();
		Drawer drawer = listDrawers.get(position);
		holder.txtDrawerItem.setText(drawer.getName());
		holder.txtDrawerItem.setCompoundDrawablesWithIntrinsicBounds(
				drawer.getDrawable(), null, null, null);
		return rowView;
	}
}
